package org.flexlancer.CommentsLibrary{
	import flash.events.MouseEvent;
	
	import mx.containers.Panel;
	import mx.controls.LinkButton;
	import mx.core.ScrollPolicy;

	public class DraggablePanel extends Panel{
		private var _closer:LinkButton=new LinkButton();
		[Embed(source="assets/img/close.png")] [Bindable] public var closePng:Class;
		
		private var C_Object:CommentObject;
		
		public function DraggablePanel(){
			super();
			_closer.addEventListener(MouseEvent.CLICK, closeMe);
			_closer.setStyle('icon', closePng);
			_closer.useHandCursor = false;
		}
		
		override protected function createChildren():void{
			super.createChildren();
			
			super.titleBar.addEventListener(MouseEvent.MOUSE_DOWN,handleDown);
			super.titleBar.addEventListener(MouseEvent.MOUSE_UP,handleUp);
			
			super.titleBar.addChild(_closer);
		}
		
		/////shahid start
		
		
		////////////shhid ends
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			_closer.width = 16;
			_closer.height = 16;
			_closer.x = super.titleBar.width - _closer.width - 8;
			_closer.y = 8;
		}
		
		private function handleDown(e:MouseEvent):void{
			stage.addEventListener( MouseEvent.MOUSE_UP, handleUp );
			//this.startDrag();
			// if ( e.target is Panel )
				this.startDrag();
				
				
		}
		private function handleUp(e:MouseEvent):void{
			this.stopDrag();
			stage.removeEventListener( MouseEvent.MOUSE_UP, handleUp );
			//this._output_panel.stopDrag();
		}
		
		private function closeMe(e:MouseEvent):void{
			this.visible = false;
		}
	}
}